package edu.uts.reekie.designer.conceptual.figures;

import org.eclipse.draw2d.AbstractBorder;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;

public class ViewComponentBorder extends AbstractBorder {

	protected static Insets insets = new Insets(8,6,8,6);
	
	public Insets getInsets(IFigure figure) {
		
		return insets;
	}

	public void paint(IFigure figure, Graphics g, Insets insets) {
		
		
		Rectangle r = figure.getBounds().getCropped(insets);
		
		g.setForegroundColor(ViewColorConstants.component);
		g.setBackgroundColor(ViewColorConstants.component);
		
		
		//Draw the sides of the border
		g.fillRectangle(r.x, r.y + 2, r.width, 6);
		g.fillRectangle(r.x, r.bottom() - 8, r.width, 6);
		g.fillRectangle(r.x, r.y + 2, 6, r.height - 4);
		g.fillRectangle(r.right() - 6, r.y + 2, 6, r.height - 4);

		//Outline the border
		g.setForegroundColor(ViewColorConstants.connectorGreen);
		g.drawLine(r.x, r.y + 2, r.right() - 1, r.y + 2);
		g.drawLine(r.x, r.bottom() - 3, r.right() - 1, r.bottom() - 3);
		g.drawLine(r.x, r.y + 2, r.x, r.bottom() - 3);
		g.drawLine(r.right() - 1, r.bottom() - 3, r.right() - 1, r.y + 2);
		

	}

}
